/**
 * 所有版权归 广西梧州 陈锦韬 所有
 *
 * @Title: PlfUserInfoForm
 * @Package com.rx.com.rx.stock.vo
 * @Description: 用户信息表单
 * @author: 陈锦韬
 * @date: 2020\9\8 0008
 * @version V1.0
 * @Copyright: 2020 陈锦韬  All rights reserved.
 */
package com.rx.school.vo;

import com.baomidou.mybatisplus.annotation.TableField;
import com.rx.core.data.RxData;
import com.rx.core.dbase.RxMarkDbMust;
import com.rx.core.util.EmptyChecker;
import com.rx.core.util.RxUtil;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.experimental.Accessors;

import java.math.BigDecimal;

/**
 * @author: Administrator
 * @Description: 成绩
 * @date: 2020\9\8 0008
 */
@RxData
@Data
@EqualsAndHashCode(callSuper = true)
@Accessors(chain = true)
public class SchScoresInfo extends RxMarkDbMust  {
    private static final long serialVersionUID = 1L;
    @TableField("STATUS")
    private String status;
    @TableField("PARENT_BID")
    private String parentBid;
    @TableField("EXAM_BID")
    private String examBid;
    @TableField("USER_BID")
    private String userBid;
    // 总分
    @TableField("SCORES")
    private BigDecimal scores;
    // 平均
    @TableField("AVG")
    private BigDecimal avg;
    // 语文
    @TableField("CHINESE_SCORES")
    private BigDecimal chineseScores;
    // 数学
    @TableField("MATH_SCORES")
    private BigDecimal mathScores;
    // 英语
    @TableField("ENGLISH_SCORES")
    private BigDecimal englishScores;
    // 物理
    @TableField("PHYSICAL_SCORES")
    private BigDecimal physicalScores;
    // 化学
    @TableField("CHEMICAL_SCORES")
    private BigDecimal chemicalScores;
    // 生物
    @TableField("BIOLOGICAL_SCORES")
    private BigDecimal biologicalScores;
    // 政治
    @TableField("POLITICAL_SCORES")
    private BigDecimal politicalScores;
    // 历史
    @TableField("HISTORY_SCORES")
    private BigDecimal historyScores;
    // 地理
    @TableField("GEOGRAPHIC_SCORES")
    private BigDecimal geographicScores;
    // 其他
    @TableField("OTHER_SCORES1")
    private BigDecimal otherScores1;
    @TableField("OTHER_SCORES2")
    private BigDecimal otherScores2;
    @TableField("OTHER_SCORES3")
    private BigDecimal otherScores3;
    @TableField("OTHER_SCORES4")
    private BigDecimal otherScores4;

    @TableField("STYLE_JSON")
    private String styleJson;
    @TableField("REMARK")
    private String remark;

    private int addScores(BigDecimal param){
        if(param == null){
            return 0;
        }
        scores = scores.add(param);
        return 1;
    }

    // 返回总分是否改变
    public boolean addAllScores(){
        BigDecimal old = getScores();
        setScores(BigDecimal.ZERO);
        int count = 0;
        count += addScores(chineseScores);
        count += addScores(mathScores);
        count += addScores(englishScores);
        count += addScores(physicalScores);
        count += addScores(chemicalScores);
        count += addScores(biologicalScores);
        count += addScores(politicalScores);
        count += addScores(historyScores);
        count += addScores(geographicScores);

        setAvg(RxUtil.Amount.divideRound(getScores(),count));

        return getScores().compareTo((BigDecimal) RxUtil.ofNull(old,BigDecimal.valueOf(-1))) != 0;
    }

    public void initScores(){
         chineseScores = BigDecimal.ZERO;
         mathScores = BigDecimal.ZERO;
         englishScores = BigDecimal.ZERO;
         physicalScores = BigDecimal.ZERO;
         chemicalScores = BigDecimal.ZERO;
         biologicalScores = BigDecimal.ZERO;
         politicalScores = BigDecimal.ZERO;
         historyScores = BigDecimal.ZERO;
         geographicScores = BigDecimal.ZERO;
    }

    public void calcTotal(SchScoresInfo schScoresInfo){
        chineseScores = RxUtil.Amount.add(chineseScores,schScoresInfo.getChineseScores());
        mathScores = RxUtil.Amount.add(mathScores,schScoresInfo.getMathScores());
        englishScores = RxUtil.Amount.add(englishScores,schScoresInfo.getEnglishScores());
        physicalScores = RxUtil.Amount.add(physicalScores,schScoresInfo.getPhysicalScores());
        chemicalScores = RxUtil.Amount.add(chemicalScores,schScoresInfo.getChemicalScores());
        biologicalScores = RxUtil.Amount.add(biologicalScores,schScoresInfo.getBiologicalScores());
        politicalScores = RxUtil.Amount.add(politicalScores,schScoresInfo.getPoliticalScores());
        historyScores = RxUtil.Amount.add(historyScores,schScoresInfo.getHistoryScores());
        geographicScores = RxUtil.Amount.add(geographicScores,schScoresInfo.getGeographicScores());
    }

}
